package com.demo.kafka;


import org.springframework.kafka.listener.BatchAcknowledgingMessageListener;
import org.springframework.kafka.support.Acknowledgment;
import org.springframework.stereotype.Component;
import java.util.List;

@Component
public class KafkaConsumerServer implements BatchAcknowledgingMessageListener {


    @Override
    public void onMessage(List list, Acknowledgment acknowledgment) {
        try {
            System.out.println("批量接收的消息："+list);
            acknowledgment.acknowledge();
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            acknowledgment.acknowledge();
        }
    }

    @Override
    public void onMessage(Object object) {
        //没这个会报错
    }
}